package com.edu.chapter09_kotlin

import java.util.Scanner

object Person {
    val name: String
        get() = age.toString() + "哈哈"

    private var age = 1

    @JvmStatic
    fun main(args: Array<String>) {
        val scan: Scanner = Scanner(System.`in`)

        while (true) {
            println("请输入第一个数字: (输入 q 结束)")
            val first = scan.next()
            if (first.toString() == "q")
                return

            println("请输入运算符：(+-*/)")
            val string = scan.next()

            println("请输入第二个数字:")
            val second = scan.next().toDouble()

            val ans = when (string) {
                "+" -> first.toDouble() + second
                "-" -> first.toDouble() - second
                "*" -> first.toDouble() * second
                "/" -> first.toDouble() / second
                else -> throw ArithmeticException()
            }
            println(ans)
        }
    }
}